﻿// ParseLib - An open source library for natural language processing.
// Copyright (C) Kais Dukes, 2012. E-mail: kais@kaisdukes.com
// http://parselib.org

using ParseLib.Corpora;

namespace ParseLib.Tagging.Brill
{
    public class Sentence
    {
        private readonly BrillToken[] _tokens;

        public Sentence(TextualUnit textualUnit, Lexicon lexicon)
        {
            // Initial tagging.
            var size = textualUnit.TokenCount;
            _tokens = new BrillToken[size];
            for (var i = 0; i < size; i++)
            {
                var token = textualUnit[i];
                var tags = lexicon[token.Text] ?? lexicon.DefaultTagList;
                _tokens[i] = new BrillToken(token, tags) {CurrentTag = tags[0]};
            }
        }

        public int TokenCount
        {
            get { return _tokens.Length; }
        }

        public BrillToken this[int index]
        {
            get { return index >= 0 && index < _tokens.Length ? _tokens[index] : null; }
        }
    }
}